<?php
namespace admin\customer;
use controller;

use model\admin\customerModel;

class customer extends controller{

    public function index(){

        $res = [
            'status'=>0
        ];

        if( !empty( $_GET['customer_id'] ) ){

            $customer_id = $_GET['customer_id'];
            $res['customer'] = customerModel::info( $customer_id );
            unset( $res['customer']['password'] );

            //todo 获取历史列表
            $res['customer']['address_list'] = customerModel::get_address_list( $customer_id );

        }else{

            $res['status'] = 1;
            $res['description'] = '请求错误';

        }

        echo json_encode( $res );

    }

    public function get_list(){

        $filter = [];
        if( !empty( $_GET['filter'] ) ){
            $filter = $_GET['filter'];
        }

        $list = customerModel::search( $filter );

        echo json_encode( $list );
    }

    public function edit(){


        $customer_id = $_GET['customer_id'];

        $data = $_POST;

        $res = [
            'status' => 0
        ];

        $res['num_rows'] = customerModel::edit( $customer_id, $data );

        echo json_encode( $res );
    }

}

